/*************************************************************
 * File: OredConditions.java
 * Copyright (c) 2012
 * Author: Huang Shaobin
 * Email: Shaobin.Software@gmail.com Shaobin_Software@163.com 
 * Date: Feb 21, 2013
 * Description: 
 ************************************************************/

package snow.core.persistence;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.commons.collections.CollectionUtils;

/**
 * 或条件
 * 
 * @author Shaobin.Software@gmail.com Shaobin_Software@163.com
 * @version 1.0
 */
public class OredConditions extends Conditions {

	private List<Conditions> oredConditions;

	public OredConditions() {
		super();
		this.oredConditions = new ArrayList<Conditions>();
	}

	public OredConditions addConditions(Conditions conditions) {
		this.oredConditions.add(conditions);
		return this;
	}

	public void clear() {
		super.clear();
		if (CollectionUtils.isNotEmpty(this.oredConditions)) {
			for (final Conditions conditions : this.oredConditions) {
				if (conditions != null) {
					conditions.clear();
				}
			}
			this.oredConditions.clear();
		}
	}

	public List<Conditions> getOredConditions() {
		return Collections.unmodifiableList(this.oredConditions);
	}
}
